@extends('layouts.application')
@section('content')
    <div class="admin-content">

        <div class="am-cf am-padding">
            <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">新增品牌</strong> /
                <small>Create A New Brand</small>
            </div>
        </div>

        @include('layouts._flash')


                <form class="am-form" action="{{ route('brands.store') }}" method="post">
                    {!! csrf_field() !!}

                    <div class="am-g am-margin-top">
                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                            商品品牌
                        </div>
                        <div class="am-u-sm-8 am-u-md-4">
                            <input type="text" class="am-input-sm" name="name" value="{{ old('name')}}">
                        </div>
                        <div class="am-hide-sm-only am-u-md-6">*必填，不可重复</div>
                    </div>

                    <div class="am-g am-margin-top">
                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                            品牌网址
                        </div>
                        <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
                            <input type="text" class="am-input-sm" name="url" value="{{ old('url')}}">
                        </div>
                    </div>

                    <div class="am-g am-margin-top">
                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                            缩略图
                        </div>

                <div class="am-u-sm-8 am-u-md-6 am-u-end col-end">
                    <div class="am-form-group am-form-file new_thumb">
                        <button type="button" class="am-btn am-btn-secondary am-btn-sm">
                            <i class="am-icon-cloud-upload" id="loading"></i> 上传新的缩略图
                        </button>
                        <input type="file" id="thumb_upload">
                    </div>


                    {{--<div class="select_thumb">--}}
                    {{--<button type="button" class="am-btn am-btn-success am-btn-sm" id="ck_thumb_upload">--}}
                    {{--<i class="am-icon-search-plus" id="loading"></i> 选择已存在的缩略图--}}
                    {{--</button>--}}
                    <input type="hidden" name="thumb">
                    {{--</div>--}}

                    <hr data-am-widget="divider" style="" class="am-divider am-divider-dashed"/>

                    <div>
                        <img src="" id="img_show" style="max-height: 200px;max-width:400px;">
                    </div>
                </div>
            </div>


            <div class="am-g am-margin-top">
                <div class="am-u-sm-4 am-u-md-2 am-text-right">
                    品牌描述
                </div>
                <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
                    <textarea rows="4" name="desc"></textarea>
                </div>
            </div>

            <img src="" alt="">

            <div class="am-g am-margin-top">
                <div class="am-u-sm-4 am-u-md-2 am-text-right">
                    是否显示
                </div>
                <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
                    <label class="am-radio-inline">
                        <input type="radio" value="1" name="is_show" checked> 是
                    </label>
                    <label class="am-radio-inline">
                        <input type="radio" value="0" name="is_show"> 否
                    </label>
                </div>
            </div>

            <div class="am-g am-margin-top">
                <div class="am-u-sm-4 am-u-md-2 am-text-right">
                    排序
                </div>
                <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
                    <input type="text" name="sort_order" class="am-input-sm" value="99">
                </div>
            </div>

            <div class="am-margin">
                <button type="submit" class="am-btn am-btn-primary am-radius">提交保存</button>
            </div>
        </form>


    </div>
@endsection

@section('js')
    <script src="/vendor/jquery.html5-fileupload.js"></script>

    <script>
        //文件上传
        var opts = {
            url: "/lxSystem/upload",
            type: "POST",
            beforeSend: function () {
                $("#loading").attr("class", "am-icon-spinner am-icon-pulse");
            },
            success: function (result, status, xhr) {
                if (result.status == "0") {
                    alert(result.info);
                    $("#loading").attr("class", "am-icon-cloud-upload");
                    return false;
                }

                var url = 'http://od9xcrkaj.bkt.clouddn.com/' + result.info;
                $("input[name='thumb']").val(url);
                $("#img_show").attr('src', url);
                $("#loading").attr("class", "am-icon-cloud-upload");
            },
            error: function (result, status, errorThrown) {
                alert('文件上传失败');
            }
        }


        $('#thumb_upload').fileUpload(opts);


    </script>

    {{--<script src="/assets/xSystem/vendor/ckfinder/ckfinder.js"></script>--}}
    {{--<script src="/assets/xSystem/js/ck_upload.js"></script>--}}

    <script>

    </script>
@endsection
